{# Config for the configuring eBGP on a /29 subnet on QFX routing instances as endpoint to SRX #}
{% for ri in device_abstract_config.get('routing_instances', []) %}
{%     if 'bgp' in ri.get('protocols',[]) %}
{%         for bgp in ri.protocols.bgp %}
set groups {{cfg_group}} routing-instances {{ri.name}} protocols bgp group {{bgp.name}} type {{bgp.type_}}
set groups {{cfg_group}} routing-instances {{ri.name}} protocols bgp group {{bgp.name}} export {{bgp.name}}-export
set groups {{cfg_group}} routing-instances {{ri.name}} protocols bgp group {{bgp.name}} local-as {{bgp.autonomous_system}}
{%                     for peer in bgp.peers %}
set groups {{cfg_group}} routing-instances {{ri.name}} protocols bgp group {{bgp.name}} peer-as {{peer.autonomous_system}}
set groups {{cfg_group}} routing-instances {{ri.name}} protocols bgp group {{bgp.name}} neighbor {{peer.ip_address}}
{%                     endfor %}
set groups {{cfg_group}} policy-options policy-statement {{bgp.name}}-export term DIRECT from protocol direct
set groups {{cfg_group}} policy-options policy-statement {{bgp.name}}-export term DIRECT then accept
{%         endfor %}{# for ri_proto.get('bgp') #}
{%     endif %}{# if bgp in ri.get('protocols',[]) #}
{% endfor %}{# for device_abstract_config.get('routing_instances', []) #}

{# Config for the interfaces of QFX to be in trunk mode #}
{% for ifd in device_abstract_config.get('physical_interfaces',[]) %}
{%    for ifl in ifd.get('logical_interfaces',[]) %}
{%        if ifl.get('comment','') == '/* PNF-Service-Chaining */' %}
set groups {{cfg_group}} interfaces {{ifd.get('name')}} unit {{ifl.get('unit')}} family {{ifl.get('family')}} interface-mode {{ifl.get('interface_mode')}}
{%            for vlan in ifl.get('vlans',[]) %}
set groups {{cfg_group}} interfaces {{ifd.get('name')}} unit {{ifl.get('unit')}} family {{ifl.get('family')}} vlan members {{vlan.get('name')}}
{%            endfor %}
{%        endif %}
{%    endfor %}
{% endfor %}
